/**
 *
 *  CheckArticleUserFilter.h
 *
 */

#pragma once

#include <drogon/HttpFilter.h>

#include <drogon/HttpController.h>
#include <drogon/orm/RestfulController.h>

#include <string>
#include <iostream> 
#include "Article.h"
using namespace drogon;
using namespace drogon_model::REFUSECLASSIFICATION;
using namespace drogon::orm;
using namespace drogon::nosql;

class CheckArticleUserFilter : public HttpFilter<CheckArticleUserFilter> {
  public:
    CheckArticleUserFilter() {}
    /**
     * @brief 验证文章操作是否合法
     * @param  req              desc
     * @param  fcb              desc
     * @param  fccb             desc
     * 
     * @details 请求格式：
     * 
     * url parameter: id:文章id
     * 
     * {
     *  "user_id": 1 // 用户id
     * }
     */
    virtual void doFilter(const HttpRequestPtr& req,
                          FilterCallback&&      fcb,
                          FilterChainCallback&& fccb) override;

    orm::DbClientPtr getDbClient()
    {
        return drogon::app().getFastDbClient(dbClientName_);
    }

    nosql::RedisClientPtr getRedisClient()
    {
        return drogon::app().getFastRedisClient(redisClientName_);
    }

  protected:
    const std::string dbClientName_{"default"};

    const std::string redisClientName_{"default"};
};
